<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" charset="UTF-8" content="width=device-width, initial-scale=1.0">
    <title>收徒赚钱</title>
    <script src="${ctx}/js/jquery1.8.2.min.js"></script>
    <script src="${ctx}/js/vue.min.js"></script>
    <link rel="stylesheet" href="${ctx}/css/reset.css">
    <script src="${ctx}/js/changeSize.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery.fileDownload/1.4.2/jquery.fileDownload.js"></script>
</head>
<style>
    html{
        background: rgb(254,224,111);
    }
    body{
        overflow-x: initial;
    }
    .bg{
        width: 100%;
        height: auto;
        position: absolute;
        z-index: -1;
    }
    .explain{
        font-size: 0.8rem;
        text-align: center;
        padding-top: 6%;
    }
    .explain img{
        width: 2.2rem;
        height: 2.2rem;
    }
    .explain h4{
        line-height: 1.5rem;
        color: #fff;
        font-size: 0.7rem;
        font-weight: 100;
        letter-spacing: 0.07rem;
    }
    .tit{
        text-align: center;
        margin-top: 14%;
        font-size: 1.6rem;
        color: #F95046;
        letter-spacing: 0.3rem;
    }
    .tit2{
        text-align: center;
        font-weight: 500;
        font-size: 0.7rem;
        color: #999999;
        letter-spacing: 0.08rem;
        margin: 5% auto;
        max-width: 10rem;
        line-height: 1rem;
    }
    .ld_box{
        width: 80%;
        height: 0.9rem;
        border-radius: 0.7rem;
        border: 0;
        background:rgba(0,0,0,0.1);
        text-align: center;
        position: relative;
        left: 0;
        right: 0;
        margin: auto;
        /*overflow: hidden;*/
        margin-top: 44%;
    }
    .sop_box{
        height: 0.9rem;
        background-image: linear-gradient(to right , #FF7C5B, #FF595E);
        border-radius: 0.9rem;
        min-width: 6%;
        max-width: 100%;
        position: relative;
    }
    .sop_box img{
        width: 0.9rem;
        height: 0.9rem;
        float: right;
    }
    .out-div {
        color: #FFFFFF;
        font-size: 0.5rem;
        line-height: 0.9rem;
        position: absolute;
        height: 1rem;
        width: max-content;
        text-align: center;
        border-radius: 0.3rem;
        right: 0;
        margin-top: -2rem;
        vertical-align: top;
        background-image: linear-gradient(to right , #FF7C5B, #FF595E);
        background: -webkit-linear-gradient(to right , #FF7C5B, #FF595E);
        background: -moz-linear-gradient(to right , #FF7C5B, #FF595E);
        padding: 0.2rem 0.5rem;
    }
    .out-div:after {
        position: absolute;
        content: '▼';
        margin-left: -0.3rem;
        margin-top: 0.9rem;
        font-size: 0.1rem;
        background: linear-gradient(to right , #FF7C5B, #FF595E);
        -webkit-background-clip: text;
        color: transparent;
    }
    .arrow {
        width: 0px;
        height: 0px;
        border-top: 8px solid;
        border-right: 10px solid transparent;
        border-left: 10px solid transparent;
        border-bottom: 10px solid transparent;
        position: absolute;
        margin-left: -0.3rem;
        margin-top: 1.2rem;
        background: linear-gradient(to right , #FF7C5B, #FF595E);
    }
    .open_app{
        width: 17rem;
        height: 2.5rem;
        border-radius: 0.8rem;
        background: url(/image/juejin/btn_gradient.png);
        background-size: 100%;
        color: #fff;
        border: 0;
        margin: 45% auto 0;
        display: block;
        text-align: center;
        text-decoration: none;
        line-height: 2rem;
    }
    .lattice_box{
        width: 16rem;
        height: 16rem;
        position: relative;
        left: 0;
        right: 0;
        margin: 3rem auto 0;
        background: url("${ctx}/image/juejin/Highlights.png");
        background-size: 100%;
        background-repeat: no-repeat;
    }
    .lattice_box li{
        width: 7.95rem;
        height: 7.95rem;
        display: block;
        text-align: center;
        float: left;
    }
    .lattice_box li:nth-child(1){
        border-bottom: 0.05rem solid #000;
    }
    .lattice_box li:nth-child(2){
        border-left: 0.05rem solid #000;
        border-bottom: 0.05rem solid #000;
    }
    .lattice_box li:nth-child(3){
        border-right: 0.05rem solid #000;
    }
    .lattice_box li img{
        width: 5rem;
        height: 5rem;
        margin-top: 1rem;
    }
    .lattice_box li span{
        font-size: 0.7rem;
        display: block;
        line-height: 1.7rem;
    }
    .open_ld{
        width: 15rem;
        height: 2.5rem;
        border-radius: 0.8rem;
        background: #00b3ee;
        color: #000;
        display: block;
        border: 0;
        margin: 3.5rem auto;
    }
</style>
<body>
<div id="app">
    <img class="bg" src="${ctx}/image/juejin/bag2.png">
    <div class="explain">
        <img src="${ctx}/image/juejin/xylogo.png">
        <h4>${appname}</h4>
    </div>
    <div v-if="type===1">
        <h2 class="tit">{{tit}}</h2>
        <h3 class="tit2">{{tit2}}</h3>
        <button class="open_app" v-if="ldtype===1" @click="appurl()">开始下载</button>
        <button class="open_app" v-if="ldtype===2">正在下载</button>
<#--        <div class="ld_box" v-if="ldtype===2">-->
<#--            <div class="sop_box"  :style="{width:per_cent}">-->
<#--                <img src="${ctx}/image/juejin/circular.png">-->
<#--                &lt;#&ndash;                <span>{{sop}}/{{total}}M</span>&ndash;&gt;-->
<#--                <div class="out-div">-->
<#--                    &lt;#&ndash;                    <div class="arrow" ></div>&ndash;&gt;-->
<#--                    <span>{{sop}}M</span>-->
<#--                </div>-->
<#--            </div>-->
<#--        </div>-->
        <a class="open_app" v-if="ldtype===3" href="adidear://start_page">打开应用</a>
        <div class="lattice_box"></div>
    </div>
    <div v-if="type===2">
        <h2 class="tit">{{nottit}}</h2>
        <h3 class="tit2">{{notcontent}}</h3>
        <button class="open_app" v-if="ldtype===1" @click="appurl()">开始下载</button>
        <button class="open_app" v-if="ldtype===2">正在下载</button>
<#--        <div class="ld_box" v-if="ldtype===2">-->
<#--            <div class="sop_box"  :style="{width:per_cent}">-->
<#--                <img src="${ctx}/image/juejin/circular.png">-->
<#--                <div class="out-div">-->
<#--                    <span>{{sop}}M</span>-->
<#--                </div>-->
<#--            </div>-->
<#--        </div>-->
        <a class="open_app" v-if="ldtype===3" href="adidear://start_page">打开应用</a>
        <div class="lattice_box"></div>
    </div>
</div>
</body>
</html>
<script>
    var app = new Vue({
        el: '#app',
        data: {
            tit:"绑定成功",
            tit2:"掘金计划下载中，请稍后",
            sop:0,
            total:0,
            per_cent:"0%",
            type:1,
            ldtype:1,
            nottit:"您已经注册",
            notcontent:"兼职咸鱼有新变化啦,回来瞧瞧吧！",
            url:"http://apk.hotbuybuy.com/xy_xyte_150.apk"
            // url:"https://c1.g.mi.com/package/AppStore/0d564479a6443e728c00418e5858c3d50b841d2e1/eyJhcGt2IjoiNTQ1MCIsIm5hbWUiOiJjb20udHV5b3UuZG91ZGl6aHUubWkiLCJ2ZXJzaW9uIjoiMS4wIiwiY2lkIjoibWVuZ18xNDM5XzVfYW5kcm9pZCIsIm1kNSI6ZmFsc2V9/9a90414a42f3c4eeb5174a553c17f69e"
        },
        mounted: function () {
            let ty= this.getQueryVariable("ty");
            let not= this.getQueryVariable("not");
            if (Number(ty)===2){
                this.type=2
            }
            if (Number(not)===2){
                this.type=2;
                this.ldtype=1;
                this.nottit="链接失效";
                this.notcontent="首次注册可获得8.5元红包"
            }
            if (Number(not)===1){
                this.type=2;
                this.ldtype=1;
            }
            if (ty===false){
                this.appurl()
            }
        },
        methods: {
            appurl(data){
                let that=this
                $.ajax({
                    url: '/api/invite/pack',
                    type: 'post',
                    data: {},
                    dataType: "json",
                    success: function (res) {
                        // let data = JSON.parse(ajax.responseText);
                        if (res.status==="200" || res.status===200){
                            that.url=res.data;
                            that.ldtype=2
                            that.open_dow()
                        }else {
                            // window.location = '/taskjuejin/download?ty=2&not=1';
                        }
                    },
                    error: function () {
                    }
                });
                // let ajax = new XMLHttpRequest();
                // ajax.open('post','http://192.168.1.40:8083/api/invite/pack');
                // ajax.send();
                // try {
                //     ajax.onreadystatechange = function () {
                //         if (ajax.status === 200) {
                //             let data = JSON.parse(ajax.responseText);
                //             if (data.status==="200" || data.status===200){
                //                 that.url=data.data;
                //                 that.open_dow()
                //             }else {
                //                 // window.location = '/taskjuejin/download?ty=2&not=1';
                //             }
                //         } else {
                //
                //         }
                //     }
                // } catch (e) {
                //
                // }
            },
            open_dow(){
                let that=this;
                that.ldtype=2;
                window.location.href=that.url
                setTimeout(function (){
                    that.ldtype=3
                }, 5000);
                // that.ldtype=2;
                // let xhr = new XMLHttpRequest();;
                // xhr.open('GET', that.url, true);
                // xhr.addEventListener('progress', function (event) {
                //     try {
                //         if (event.lengthComputable) {
                //             let percentComplete = event.loaded / event.total;
                //             // let left = containerWidth * percentComplete;
                //             that.sop=Math.round((event.loaded/1024)/1024)
                //             that.per_cent=(percentComplete*100)+"%";
                //             that.total=Math.round((event.total/1024)/1024)
                //             if(percentComplete===1){
                //                 // console.log("下载完成");
                //                 that.tit="下载完成";
                //                 that.tit2="24小时内打开应用并登录否则失效";
                //                 that.ldtype=3;
                //                 // that.type=1
                //             }
                //             // console.log(percentComplete); // 最后输出1
                //         }
                //     }catch (e) {
                //         console.log(e)
                //     }
                // }, false);
                // xhr.responseType = "blob";
                // xhr.onload = function () {
                //     if (xhr.readyState === 4 && xhr.status === 200) {
                //         // var filename = $(that).data('filename');
                //         if (typeof window.chrome !== 'undefined') {
                //             // Chrome version
                //             var link = document.createElement('a');
                //             link.href = window.URL.createObjectURL(xhr.response);
                //             link.download = "兼职咸鱼";
                //             link.click();
                //         } else if (typeof window.navigator.msSaveBlob !== 'undefined') {
                //             // IE version
                //             var blob = new Blob([xhr.response], { type: 'application/force-download' });
                //             window.navigator.msSaveBlob(blob, "兼职咸鱼");
                //         } else {
                //             // Firefox version
                //             var file = new File([xhr.response], "兼职咸鱼", { type: 'application/force-download' });
                //             window.open(URL.createObjectURL(file));
                //         }
                //     }
                // };
                // xhr.onreadystatechange = function () {
                //     if (xhr.readyState === 4 && xhr.status === 200) {
                //         var filename = $(that).data('filename');
                //         if (typeof window.chrome !== 'undefined') {
                //             // Chrome version
                //             let link = document.createElement('a');
                //             link.href = window.URL.createObjectURL(xhr.response);
                //             link.download = "兼职咸鱼";
                //             link.click();
                //         } else if (typeof window.navigator.msSaveBlob !== 'undefined') {
                //             // IE version
                //             let blob = new Blob([xhr.response], { type: 'application/force-download' });
                //             window.navigator.msSaveBlob(blob, "兼职咸鱼");
                //         } else {
                //             // Firefox version
                //             let file = new File([xhr.response], "兼职咸鱼", { type: 'application/force-download' });
                //             window.open(URL.createObjectURL(file));
                //         }
                //     }
                // };
                // xhr.send();
            },
            getQueryVariable(variable)
            {
                var query = window.location.search.substring(1);
                var vars = query.split("&");
                for (var i=0;i<vars.length;i++) {
                    var pair = vars[i].split("=");
                    if(pair[0] == variable){return pair[1];}
                }
                return(false);
            }
        }
    });

</script>
